﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Net;
using System.IO;
using System.Net.Sockets;
using System.Threading;

using Model; 




namespace Kontroller
{
    public class AuktionariusKlient
    {

        public Forbindelse Forbindelse;
        public ServerListener ServerListener;

        private Thread _serverListenerThread;

        public delegate void ServerEventType(string besked);
        public event ServerListener.ServerEventType ServerEvent;
        public ServerEventType ServerBesked; 

       

        

        public AuktionariusKlient(int port, string adr)
        { 
      
            Forbindelse = new Forbindelse(port, adr); 
            ServerListener = new ServerListener(Forbindelse);
            
        }
        


        public void Logon()
        {
            Forbindelse.Logon();
            _serverListenerThread = new Thread(ServerListener.Listen);
            _serverListenerThread.Start();
            ServerListener.ServerEvent += ModtagBesked;
        }

        public void ModtagBesked(string besked)
        {
            ServerBesked(besked);
        }

        public void SendTilServer(string besked)
        {
            Forbindelse.SendTilServer(besked);
        }

        







    }
}
